{% extends "base.html" %}
{% load url from future %}
{% load humanize %}
{% load i18n %}

{% block content %}
    <h1>Report #{{ report.id }}</h1>

    <table>
        <tr>
            <th>Planet :</th>
            <td>{{ report.planet.name }}</td>
        </tr>
        <tr>
            <th>Coordinates :</th>
            <td>
                <a href="{% url 'show_planet' report.planet.id %}">
                    {{ report.planet.galaxy }}:{{ report.planet.ss|escape }}:{{ report.planet.position }}
                </a>
            </td>
        </tr>
        <tr>
            <th>Planet Owner :</th>
            <td>
                <a href="{% url 'show_player' report.planet.player.id %}">
                    {{ report.planet.player.name }}
                </a>
            </td>
        </tr>
        <tr>
            <th>Report made by :</th>
            <td>{{ report.user.username }}</td>
        </tr>
        <tr>
            <th>Report Date : </th>
            <td>{{ report.date }}</td>
        </tr>
    </table>

    <br />

    <table>
        <tr>
            <th style="width:20%;">{% trans 'Resources' %}</th>
            <th style="width:20%;">{% trans 'Ships & Defenses' %}</th>
            <th style="width:20%;">{% trans 'Army' %}</th>
            <th style="width:20%;">{% trans 'Constructions' %}</th>
            <th style="width:20%;">{% trans 'Researches' %}</th>
        </tr>
        <tr>
            <td class="center"><img class="mini" src="{{ STATIC_URL }}/{% if report.contain_resource %}check{% else %}cancel{% endif %}.png" /></td>
            <td class="center"><img class="mini" src="{{ STATIC_URL }}/{% if report.contain_ship %}check{% else %}cancel{% endif %}.png" /></td>
            <td class="center"><img class="mini" src="{{ STATIC_URL }}/{% if report.contain_army %}check{% else %}cancel{% endif %}.png" /></td>
            <td class="center"><img class="mini" src="{{ STATIC_URL }}/{% if report.contain_construction %}check{% else %}cancel{% endif %}.png" /></td>
            <td class="center"><img class="mini" src="{{ STATIC_URL }}/{% if report.contain_research %}check{% else %}cancel{% endif %}.png" /></td>
        </tr>
    </table>

    {% if report.contain_resource %}
        <h2>{% trans 'Resources' %}</h2>
        <table>
            <tr>
                {% for res in report.get_resources %}
                        <th style="width: 25%;">{% trans res.resource %} :</th>
                {% endfor %}
            </tr>
            <tr>
                {% for res in report.get_resources %}
                        <td class="strong center">{{ res.quantity|intcomma }}</td>
                {% endfor %}
            </tr>
        </table>
    {% endif %}

    {% if report.contain_army and report.get_army|length > 0 %}
    <h2>Army</h2>
    <table>
        <tr>
            <th style="width: 100px;">{% trans 'Unit' %}</th>
            <th>{% trans 'Quantity' %}</th>
        </tr>
        {% for res in report.get_army %}
            <tr>
                <td>{{ res.unit.name }} :</td>
                <td class="strong">{{ res.quantity|intcomma }}</td>
            </tr>
        {% endfor %}
    </table>
    {% endif %}

    {% if report.contain_construction %}
    <h2>{% trans 'Buildings' %}</h2>
    <table>
        <tr>
            <th style="width: 100px;">{% trans 'Level' %}</th>
            <th>{% trans 'Building' %}</th>
        </tr>
        {% for construction in report.get_constructions %}
            <tr>
                <td class="strong center">
                    {{ construction.level }}
                </td>
                <td>
                    {{ construction.building.name }}
                </td>
            </tr>
        {% endfor %}
    </table>
    {% endif %}


    {% if report.contain_research %}
    <h2>{% trans 'Researches' %}</h2>
    <table>
        <tr>
            <th style="width: 100px;">{% trans 'Level' %}</th>
            <th>{% trans 'Technology' %}</th>
        </tr>
        {% for technology in report.get_researches %}
            <tr>
                <td class="strong center">
                    {{ technology.level }}
                </td>
                <td>
                    {{ technology.technology.name }}
                </td>
            </tr>
        {% endfor %}
    </table>
    {% endif %}

    <h2>{% trans 'Raw Report' %}</h2>
    {{ report.raw_report|linebreaksbr }}

{% endblock %}
